<template>
  <!-- // 分配角色 -->
  <div>
    <div>
      <el-checkbox-group v-model="roleIds">
        <el-checkbox v-for="item in roleList" :key="item.id" :label="item.id">{{ item.name }}</el-checkbox>
      </el-checkbox-group>
    </div>
    <div style="margin-top: 20px; text-align: right">
      <el-button type="primary">确定</el-button>
      <el-button @click="closeDialog">取消</el-button>
    </div>
  </div>
</template>
<script>
import { getRoles } from '@/api/settings'

export default {
  data() {
    return {
      roleIds: [],
      roleList: [] // 当前所有的角色信息
    }
  },
  created() {
    // 获取系统中已有的角色列表
    this.loadRoles()
  },
  methods: {
    async loadRoles() {
      // page: 请求的页数
      // pagesize: 每页几条
      const res = await getRoles({ page: 1, pagesize: 1000 })
      console.log('----roles', res)
      this.roleList = res.data.rows
    },
    closeDialog() {

    }
  }
}
</script>